/*
package yz.com.javautil.test;

import cn.hutool.core.collection.CollectionUtil;
import com.xinan.dataservice.sys.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

*/
/**
 * <ol>
 * date:2021-01-26 editor:dingshuangbo
 * <li>创建文档</li>
 * <li>基础工具</li>
 * </ol>
 *
 * @author <a href="mailto:2449709309@qq.com">dingshuangbo</a>
 * @version 1.0
 * @since 1.0
 *//*


@Component
@Slf4j
public class BaseUtils {
    public static Map<String, String> sysConfig = new HashMap<String, String>();
    @Autowired
    private ISysConfigService sysConfigService;

    @Value("${spring.cloud.client.ip-address}")
    public String serverIp;
    @Value("${server.port}")
    public String serverPort;

    @PostConstruct
    public void init() {
        log.info("系统启动，开始加载sysConfig");
        List<Map> sysConfigList = sysConfigService.select("sysConfig.selectSysConfig", null);
        for (Map config : sysConfigList) {
            sysConfig.put(MapUtils.getString(config, "key", ""), MapUtils.getString(config, "value", ""));
        }
    }

    @PreDestroy
    public void destroy() {
        log.info("系统停止运行");
    }

    */
/**
     * 返回某配置项的值
     *
     * @param key
     * @return
     *//*

    public String getSysConfigValue(String key) {
        return MapUtils.getString(sysConfig, key, "");
    }

    */
/**
     * 获取GP序列
     *//*

    public String getGpSeq() {
        return (String) sysConfigService.selectOne("common.selectGpSeq", null);
    }

    */
/**
     * 带逗号的字符串转换成SQL里的inStr（"a,b,c"->'a','b','c'）
     *
     * @param stringWithComma 用逗号分隔的字符串 "a,b,c"
     * @return inStr可以用在SQL的in语句内 'a','b','c'
     *//*

    public String getInStr(String stringWithComma) {
        String splitSymbolComma = ",";
        ArrayList<String> strList = CollectionUtil.toList(stringWithComma.split(splitSymbolComma));
        return strList.stream().collect(Collectors.joining("\',\'", "\'", "\'"));
    }

    */
/**
     * 未分页数据根据参数进行分页
     *
     * @param rows     未分页的数据记录
     * @param curPage  页码（从1开始）
     * @param pageSize 每页记录数据
     * @return 当前页码的记录数据
     *//*


    public List<Map<String, Object>> rowsToPageRows(List<Map<String, Object>> rows, int curPage, int pageSize) {
        int totalSize = rows.size();
        int totalPage = ((Double) Math.ceil(totalSize * 1.0 / pageSize)).intValue();
        // 当前页大于总页数
        if (curPage > totalPage) {
            return null;
        }
        // 计算的 toIndex 大于总记录数则取总条数
        int toIndex = pageSize * curPage;
        if (toIndex > totalSize) {
            toIndex = totalSize;
        }
        return rows.subList(pageSize * (curPage - 1), toIndex);
    }
}

*/
